import javafx.scene.image.Image;
import sun.misc.BASE64Encoder;

import java.io.*;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.jar.JarFile;

/**
 *
 * 获取图片的base64编码 以及宽高
 *
 * Created by Zhou_Bing on 2019/3/13.
 */
public class image {


    public static void main(String[] args) throws IOException {

        File image = new File(new String("D:\\测试 图片\\3_2.png".getBytes(), "UTF-8"));

        InputStream in = new BufferedInputStream(new FileInputStream(image));

        byte[] data = new byte[in.available()];
        in.read(data);

        BASE64Encoder encoder = new BASE64Encoder();
        System.out.println(encoder.encode(data));

        Long start = System.currentTimeMillis();
        Image image1 = new Image(new FileInputStream(image));
        System.out.println(image1.getWidth()+","+image1.getHeight());
        System.out.println("耗时:"+(System.currentTimeMillis()-start));
    }
}
